﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Facebook.Web
{
    /// <summary>
    /// This class is responsable to retrieve the necessary configuration data
    /// </summary>
    public class AuthRequestArgs
    {
        /// <summary>
        /// Facebook ApplicationID
        /// </summary>
        public string ApplicationID { get; set; }
        /// <summary>
        /// Facebook APIKey associated with this application
        /// </summary>
        public string APIKey { get; set; }

        /// <summary>
        /// Unique id that identifies the application
        /// </summary>
        /// 
        public string AppSecret { get; set; }

        /// <summary>
        /// Url  that alow the aplication to access the Facebook Graph API
        /// </summary>
        public string GraphpUrl { get; set; }

        /// <summary>
        /// Url that alow the aplication to make FQL Queries
        /// </summary>
        public string FqlUrl { get; set; }

        /// <summary>
        /// Url of the application. This url must be url that the administrator register on the facebook 
        /// </summary>
        public string ApplicationUri { get; set; }
        
        /// <summary>
        /// Facebook Authentication Url 
        /// </summary>
        public string ApplicationOAuthUrl { get; set; }
        /// <summary>
        /// Application needed Permissions 
        /// </summary>
        public string UserPermissions
        {
            get
            {
                if (Config.AppSettings.Settings.Count > 0)
                {
                    return Config.AppSettings.Settings["apppermissions"].Value;
                }
                return "read_stream";
            }
        } 

        private System.Configuration.Configuration config;

        /// <summary>
        /// Configuration Instance to retrieve all the configuration from the configuration file of the application
        /// </summary>
        public System.Configuration.Configuration Config
        {
            get { return config; }
            set
            {
                config = value;
                if (value != null && value.AppSettings.Settings.Count > 0)
                {
                    ApplicationID = value.AppSettings.Settings["applicationID"].Value;
                    APIKey = value.AppSettings.Settings["APIKey"].Value;
                    AppSecret = value.AppSettings.Settings["AppSecret"].Value;
                    GraphpUrl = value.AppSettings.Settings["graphUrlRequests"].Value;
                    FqlUrl = value.AppSettings.Settings["fqlUrl"].Value;
                    ApplicationUri = value.AppSettings.Settings["applUrl"].Value;
                    ApplicationOAuthUrl = value.AppSettings.Settings["ApplicationOAuthUrl"].Value;
                }

            }
        }

        
    }
}